package com.changgou.service.impl;

import com.changgou.dao.UserInfoMapper;
import com.changgou.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: hushengjin
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    /**
     * 账户金额递减
     *
     * @param username
     * @param money
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean decrMoney(String username, int money) {
        int i = userInfoMapper.decrMoney(username, money);
        //int a = 10 / 0;
        return i > 0;
    }
}
